{extend name="public/base" /}

{block name="title"}<title>我的审核</title>{/block}

{block name="pjax_container"}
<style>
    .col-sm-2{
        width: 23.666667%;
        height: 33px;
        line-height: 40px;
        padding-top: 15px;
    }
    .col-sm-7{
        padding-top: 15px;
    }
    tr>th,
    td {
        text-align: center;
    }

    .btn-group-xs>.btn,
    .btn-xs {
        padding: 5px;

    }

    .content-header>.breadcrumb>li{
        color: #999;
    }
    .content-header>.breadcrumb>.active{
        color: #666;
    }
    .content-header{
        height: 51px;

    }
    .btn-primary{
        background-color: #1890FF;
        color: #fff;
        border: none;
        border-radius: 6px !important;
        padding: 7px 10px;
    }
    .box-primary{
        border-top-color: #ecf0f5 !important;
        border-top-width: 16px;

    }
    .btn-primary:hover{
        background-color: #1890FF;
        color: #fff;
        border: none;
        opacity: .9;
        border-radius: 6px !important;
    }
    .btn-success {
        border-radius: 6px;
        border: none;
        outline: none;
        margin: 5px;
    }
    .delete-one{
        background-color: ff4141 !important;
        margin-left: 15px;
        border-radius: 6px;
    }
    .sreachs{
        background-color: #1890FF;
        color: #fff;
        border: none;
        border-radius: 6px !important;
        margin-left: 15px;
        padding: 7px 15px;
    }




    .modal-content {
        margin-top: 150px;
        /*width: 600px;*/
        /*height: 690px;*/

    }

    .modal-body {
        padding: 27px;
        /*width: 856px;*/
        /*height: 570px;*/
        display: flex;
    }

    .modal-right {
        flex: 1;
        border: 1px solid #eee;
        margin-left: 30px;
    }

    .modal-left {
        height: 100%;
    }

    .modal-right>h4 {
        width: 100%;
        display: flex;
        justify-content: space-around;
    }

    .form-control {
        border-radius: 6px;
    }

    .table-body {
        width: 540px;
        height: 462px;
        border-radius: 6px;
        background-color: #eee;
    }

    .table-left {
        margin-right: 2%;
        width: 49%;
        height: 100%;
        float: left;
        border: 1px solid #eee;
        background-color: #fff;
    }

    .table-right,
    .table-right2 {
        width: 49%;
        height: 100%;
        border: 1px solid #eee;
        float: left;
        padding-top: 10px;
        background-color: #fff;
    }





    .btn-danger{
        border: none;
        outline: none;
        padding: 8px 10px;
    }
    .timepicker{
        margin: 10px 5px !important;
    }
    .pagination .active{
        background-color: #1890FF;
    }
    .form-horizontal>a{
        margin: 5px;
        padding: 8px 10px;
        height: 34px;
    }
    .layui-form-checkbox[lay-skin=primary] i {
        position: absolute;
        left: -70%;
        top: 50%;
    }
    .layui-form-checked[lay-skin=primary] i {
        background-color: #1890FF;
        background-color: #1890FF;
        color: #fff;
        position: absolute;
        left: -70%;
        top: 50%;
    }
    .layui-input-block {
        margin-left: 50px;
        min-height: 36px;
    }
    .cont-bottom{
        background-color: #fff;
        width: 100%;
        margin-top: 32px;
    }
    .row{
        margin-left: 0;
        margin-right: 0;
    }
    .box-primary {
        border-top-color: transparent !important;
        border-top-width: 0px;
    }
    .tab-content {
        margin: 20px 0 40px;
        border-bottom: 0px solid #f3f3f3;
        padding-bottom: 40px;
    }
    .box-border{
        width: 100%;
        height: 42px;
        border-radius: 6px;
        border: 1px solid #1890FF;
        margin: 20px auto;
        background-color: #e6f7ff;
        line-height: 42px;
        display: flex;
    }
    .box-border>p{
        width: 100%;
        padding-left: 30px;
        letter-spacing: 1px;
        position: relative;
    }
    .box-border>p>a{
        margin-left: 10px;
    }
    .box-border>p>b{
        color: #1890FF;
        margin-right: 5px;
    }
    .box-border>p>input{
        background-color: #f5f5f5;
        height: 30px;
        width: 60px;
        line-height: 30px;
        border: none;
        outline: none;
        color: #d9d9d9;
        border: 1px solid #d9d9d9;
        float: right;
        border-radius: 6px;
        margin-top: 5.5px;
        margin-right: 10px;
    }
    form{
        width: 100%;
        overflow: hidden;
    }
    form>label{
        float: left;
        margin-left: 10px;
    }
    .input-group input{
        width: 233px;
        height: 34px;
        border-radius: 6px;
        border: 1px solid #ccc;
        margin-left: 10px;
        margin-right: 10px;
    }
    select{
        width: 233px;
        height: 28px;
        border-radius: 6px;
        border: 1px solid #ccc;
        margin-left: 10px;
        font-size: 13px;
    }

    select>option{
        margin-top: 10px;
    }
    .select2-container--default .select2-selection--single, .select2-selection .select2-selection--single {
        border: 1px solid #d2d6de;
        border-radius: 6px;
        padding: 6px 12px;
        height: 34px;
    }
    .plch{background-color: red}
    .plbh{background-color: #f39c12;
}
</style>
<section class="content-header">
    <ol class="breadcrumb">
        <li>积分管理</li>
        <li class="active">我的审核</li>
    </ol>
</section>

<div class="row cont-bottom">
    <ul class="nav nav-tabs" style="position: relative;">
        <li class='{if condition="input('list_type')==0"}active{/if}'><a href="{:url('my_audit',['list_type'=>0])}">全部</a></li>
        <li class='{if condition="input('list_type')==1"}active{/if}'><a href="{:url('my_audit',['list_type'=>1])}">待审核</a></li>
        <li class='{if condition="input('list_type')==2"}active{/if}'><a href="{:url('my_audit',['list_type'=>2])}">我已审核</a></li>
        <li class='{if condition="input('list_type')==3"}active{/if}'><a href="{:url('my_audit',['list_type'=>3])}">抄送给我的奖扣</a></li>
    </ul>
    <div class="tab-content" style="position: relative;">
        <div id="tab1" class="tab-pane active">
            <div class="col-md-12">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <form action="{:search_url(['theme', 'first_check_user_id', 'last_check_user_id', 'record_user_id', 'prize_buckle_time', 'create_time', 'status'])}" method="GET">
                        <div class="input-group input-group-sm">
                            <input type="hidden" name="page" value="1" />
                            <label>
                                事件主题: <input type="text" name="theme" value="{:input('get.theme','')}" id="" placeholder="请输入事件主题" autocomplete="off"  />
                            </label>
                            <label>
                                初　审人:                                
                            </label>
                            <div class="xyqk_input">
                                    <input type="text" name="first_check_user_name" class="first_check_user_name" value="{:input('get.first_check_user_name','')}" placeholder="" autocomplete="off"  />
                                    <input type="hidden" name="first_check_user_id" class="first_check_user_id" value="{:input('get.first_check_user_id','')}" >
                                    <div class="delect_btn_an" style="right: 15px; top: 6px;"><i class="fa fa-remove"></i></div>
                            </div>
                            <label>
                                终　审人:
                            </label>
                            <div class="xyqk_input">
                                     <input type="text" name="last_check_user_name" class="last_check_user_name" value="{:input('get.last_check_user_name','')}" placeholder="" autocomplete="off"  />
                                <input type="hidden" name="last_check_user_id" class="last_check_user_id" value="{:input('get.last_check_user_id','')}" >
                                    <div class="delect_btn_an" style="right: 15px; top: 6px;"><i class="fa fa-remove"></i></div>
                            </div>
                            <label>
                                记　录人:
                            </label>
                            <div class="xyqk_input">
                                <input type="text" name="record_user_name" class="record_user_name" value="{:input('get.record_user_name','')}" placeholder="" autocomplete="off"  />
                                <input type="hidden" name="record_user_id" class="record_user_id" value="{:input('get.record_user_id','')}" >
                                    <div class="delect_btn_an" style="right: 15px; top: 6px;"><i class="fa fa-remove"></i></div>
                            </div>
                            <label>
                                奖扣时间: <input type="text" name="prize_buckle_time" autocomplete="off" value="{:input('get.prize_buckle_time','')}" id="test10" placeholder="">
                            </label>
                            <label>
                                记录时间: <input type="text" name="create_time" value="{:input('get.create_time','')}" id="test11" placeholder="">
                            </label>
                            <label>
                                状　　态:
                                <select name="status" style="height: 34px;">
                                    <option value="-1" {if condition="input('status', '-1') == -1"}selected{/if} >全部</option>
                                    <option value="0" {if condition="input('status', '-1') == 0"}selected{/if} >待初审</option>
                                    <option value="1" {if condition="input('status', '-1') == 1"}selected{/if} >待终审</option>
                                    <option value="2" {if condition="input('status', '-1') == 2"}selected{/if} >审核通过</option>
                                </select>
                            </label>
                            <div class="input-group-btn" style="display: inline-block;margin-left:10px;">
                                <button type="submit" class="btn btn-default sreachs">
                                    <i class="fa fa-search"></i> 查询
                                </button>
                            </div>
                        </div>
                            
                        </form>
                    </div>


                    <div class="box-header with-border">
                        <div class="pull-left">
                            <a class="btn btn-primary plsh" href="javascript:void(0);" data-url="/company/integral/audit_pass_list" data-title="确认通过?"><i class="fa fa-check"></i> 批量通过</a>
                            <a class="btn btn-primary plbh" href="javascript:void(0);" data-url="/company/integral/audit_reject_list" data-title="确认驳回?"><i class="fa fa-repeat"></i> 批量驳回</a>
                            <a class="btn btn-primary plch" href="javascript:void(0);" data-url="/company/integral/audit_withdraw_list" data-title="确认撤回?"><i class="fa fa-reply"></i> 批量撤回</a>
                        </div>

                    </div>
                    <div class="box-body table-responsive">
                        <table class="table table-bordered table-hover">
                            <tr>
                                <th width="35"><input type="checkbox" class="minimal checkbox-toggle"></th>
                                <th>奖扣时间</th>
                                <th>记录时间</th>
                                <th>主题</th>
                                <th>A分</th>
                                <th>B分</th>
                                <th>人次</th>
                                <th>记录人</th>
                                <th>初审人</th>
                                <th>终审人</th>
                                <th>审核状态</th>
                                {if condition="input('list_type') != 3"}
                                <th>操作</th>
                                {/if}
                            </tr>
                            {volist name="list" id="v"}
                            <tr>
                                <td><input type="checkbox" name="id[]" value="{$v.id}" data-status="{$v.status}" data-fuser="{$v.first_check_user_id}" data-luser="{$v.last_check_user_id}" data-ruser="{$v.record_user_id}" class="minimal checkbox"></td>
                                <td>{:date('Y-m-d',$v.prize_buckle_time)}</td>
                                <td>{:date('Y-m-d H:i:s',$v.create_time)}</td>
                                <td><a href="{:url('integral/event_info',['id'=>$v.id])}">{$v.theme}</a></td>
                                <td>{$v.integral_a_add + $v.integral_a_del}</td>
                                <td>{$v.integral_b_add + $v.integral_b_del}</td>
                                <td>{$v.people_sum}</td>
                                <td>{$users_data[$v.record_user_id]}</td>
                                <td>{$users_data[$v.first_check_user_id]??''}</td>
                                <td>{$users_data[$v.last_check_user_id]??''}</td>
                                <td>
                                    {if condition="$v.status eq 0"}
                                    待初审
                                    {elseif condition="$v.status eq 1"}
                                    待终审
                                    {elseif condition="$v.status eq 2"}
                                    审核通过
                                    {elseif condition="$v.status eq 3"}
                                    作废
                                    {elseif condition="$v.status eq 4"}
                                    拟稿
                                    {/if}
                                {if condition="input('list_type') != 3"}
                                    <td>

                                        <form class="form-horizontal" style="display: inline-block" method="POST"
                                              action="{:url('audit_pass')}" onsubmit="return false" data-status="{$v.status}" data-fuser="{$v.first_check_user_id}" data-luser="{$v.last_check_user_id}">
                                            <input type="hidden" name="id" value='{$v["id"]}' />
                                            <!--审核，驳回意见-->
                                            <input type="hidden" class="check_opinion" name="check_opinion" value='' />
                                            {if condition="in_array($v.status,[0,1])"}
                                            <!--通过-->
                                            <!--驳回-->
                                                {if condition="$v.status == 0 && $v.first_check_user_id == $user_id"}
                                                <button type="submit" class="btn btn-sm btn-primary audit_sub_submit tg"><i class='fa fa-save'></i>
                                                    通过</button>
                                                <button type="submit" class="btn btn-sm btn-warning bh_sub_submit bh"><i
                                                        class='fa fa-repeat'></i> 驳回</button>
                                                {elseif condition="$v.status == 1 && $v.last_check_user_id == $user_id"}
                                                <button type="submit" class="btn btn-sm btn-primary audit_sub_submit tg"><i class='fa fa-save'></i>
                                                    通过</button>
                                                <button type="submit" class="btn btn-sm btn-warning bh_sub_submit bh"><i
                                                        class='fa fa-repeat'></i> 驳回</button>
                                                {/if}
                                            <!--催审-->
                                                {if condition="$v['record_user_id'] == $user_id"}
                                                    <a class='btn btn-sm btn-success audit-urge' href='javascript:void(0);' data-url="{:url('audit_urge')}" data-id="{$v['id']}"><i class='fa fa-volume-up'></i> 催审</a>
                                                {/if}
                                            {/if}

                                            <!--撤回-->
                                            {if condition="$v.status == 1 && $v.first_check_user_id == $user_id"}
                                                <button type="submit" class="btn btn-sm btn-danger ch_sub_submit ch"><i class='fa fa-reply'></i> 撤回</button>
                                            {/if}
                                            {if condition="$v.status == 2 && $v.last_check_user_id == $user_id"}
                                                <button type="submit" class="btn btn-sm btn-danger ch_sub_submit ch"><i class='fa fa-reply'></i> 撤回</button>
                                            {/if}
                                            <button class="submits hidden"></button>
                                        </form>
                                    </td>
                                {/if}
                            </tr>
                            {/volist}
                        </table>
                    </div>

                    <div class="box-footer clearfix" style="display: flex;justify-content: flex-end;">
                        {$list->render()}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>

    /*
    *  全部 "{:url('integral/my_audit')}"
    *  待审核 "{:url('integral/my_audit', ['list_type'=>1])}"
    *  我已审核 "{:url('integral/my_audit', ['list_type'=>2])}"
    *  抄送给我的奖扣 "{:url('integral/my_audit', ['list_type'=>3])}"
    */
    $(function () {
        $(".select2").select2({language:"zh-CN"});

        // 列表部分 全选
        $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
            checkboxClass: 'icheckbox_minimal-blue',
            radioClass: 'iradio_minimal-blue'
        });
        $('.checkbox-toggle').on('ifChecked', function (event) {
            var _this = $(this);
            var _table = _this.closest('.table');
            _table.find("tr td input[type='checkbox']").iCheck("check");
        });
        $('.checkbox-toggle').on('ifUnchecked', function (event) {
            var _this = $(this);
            var _table = _this.closest('.table');
            _table.find("tr td input[type='checkbox']").iCheck("uncheck");
        });
    });

    layui.use(['form', 'layedit', 'laydate'], function () {
        var nowtime = "{:date('Y-01-01 H:i:s',time())}";
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;
        laydate.render({
            elem: '#test10'
            // ,min: nowtime //0天前
            , type: 'date'
            , range: true
        });
        laydate.render({
            elem: '#test11'
            // ,min: nowtime //0天前
            , type: 'date'
            , range: true
        });
    });

    //点击撤回，修改from提交地址
    $('.bh').on('click',function () {
        $(this).parents(".form-horizontal").attr('action',"{:url('audit_reject')}");
    })
    $('.ch').on('click',function () {
        $(this).parents(".form-horizontal").attr('action',"{:url('audit_withdraw')}");
    })
    $('.tg').on('click',function () {
        $(this).parents(".form-horizontal").attr('action',"{:url('audit_pass')}");
    })

    let input = document.querySelectorAll("input[type='text']");
    input.forEach(function(item,index){
        input[index].onfocus = function(){
            this.style.borderColor = "#1890FF";
        }
        input[index].onblur = function(){
            this.style.borderColor = "#ccc";
        }
    })

</script>


<script>
    //批量审核
    $('.plsh,.plbh').on('click', function(){
        var $tmpStatus = [];
        var msg = '';
        var type = 0;
        $(".checkbox:checked").each(function(){
            //判断状态
            if($tmpStatus.length < 1){
                $tmpStatus.push($(this).data('status'));
            }else if($.inArray($(this).data('status'),$tmpStatus) < 0){
                // layui.layer.msg('不同状态，不能批量操作');
                msg = '不同状态，不能批量操作';
                return false;
            }
        });
        if($tmpStatus.length == 0){
            layui.layer.msg('请选择');
            return false;
        }
        if(msg != ''){
            layui.layer.msg(msg);return false;
        }
        //判断人
        var $status = $tmpStatus[0];
        $(".checkbox:checked").each(function(){
            if($status === 0){
                if($(this).data('fuser') != {$user_id}) {
                    layui.layer.msg('批量操作数据初审人，必须是同一审核人');
                    type = 1;
                }
            }else if($status == 1){
                if($(this).data('luser') != {$user_id}) {
                    layui.layer.msg('批量操作数据终审人，必须是同一审核人');
                    type = 1;
                }
            }else{
                layui.layer.msg('非审核状态，不能批量操作');
                type = 1;
            }
        });
        if(type == 1){
            // layui.layer.msg('非审核状态，不能批量操作');
            return false;
        }
        ajax_submit_all(this);
    });

    //批量撤回
    $('.plch').on('click', function(){
        var $status = '';
        var msg = '';
        var type = 0;
        var $tmpStatus = [];
        $(".checkbox:checked").each(function(){
            $tmpStatus.push($(this).data('status'));
            //判断状态
            if($(this).data('status') > 2 || $(this).data('status') < 1) {
                // layui.layer.msg('不同状态，不能批量操作');
                msg = '不同状态，不能批量操作';
                return false;
            }
            $status = $(this).data('status');
        });
        if($tmpStatus.length == 0){
            layui.layer.msg('请选择');
            return false;
        }
        if(msg != ''){
            layui.layer.msg(msg);return false;
        }
        //判断人
        $(".checkbox:checked").each(function(){
            if(($status == 2 && $(this).data('luser') == "{$user_id}")||($status == 1 && $(this).data('fuser') != "{$user_id}")){
            }else {
                layui.layer.msg('批量撤回，状态不正确！');
                type = 1;
            }
        });
        if(type == 1){
            return false;
        }
        ajax_submit_all(this);

    });

    // //批量驳回
    // $('.plbh').on('click', function(){
    //     var msg = '';
    //     var type = 0;
    //     $(".checkbox:checked").each(function(){
    //         //判断状态
    //         if($(this).data('status') != 4) {
    //             // layui.layer.msg('不同状态，不能批量操作');
    //             msg = '不同状态，不能批量操作';
    //             return false;
    //         }
    //     });
    //
    //     if(msg != '') layui.layer.msg(msg);return false;
    //
    //     //判断人
    //     $(".checkbox:checked").each(function(){
    //         if($(this).data('ruser') != "{$user_id}"){
    //             layui.layer.msg('批量删除，必须是同一记录人');
    //             return false;
    //         }
    //     });
    // });

</script>


<!-- Modal 弹出层重写 单选  -->
<link rel="stylesheet" href="__STATIC__/global/an_tree_css/an_tree_css.css">
<div class="modal fade" id="myModal_single" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">人员选择</h4>
            </div>
            <div class="modal-body">
                <div class="modal-left">
                    <div class="modal-left-title" style="margin-bottom: 20px;">
                        <div class="input-group">
                            <input name="search_user_name" type="text" class="form-control" placeholder="">
                            <span class="input-group-btn">
                                <button class="btn btn-info search_btn" type="button"
                                    style="width: 47px; height: 34px; background-color: #1890FF;border: none;outline: none;">
                                    <span class="glyphicon glyphicon-search"></span>
                                </button>
                            </span>
                        </div>
                    </div>
                    <div class="input-group table-body">
                        <div class="table-left">
                            <div class="an_tree">

                            </div>
                        </div>
                        <div class="table-right">
                            <div class="an_tree_list">
                                <div class="an_list_title">

                                </div>
                                <div class="an_list_con">
                                    <!-- <div class="an_list_item">
                                        <div class="item_info">
                                            <span class="name">aaa</span>/
                                            <span>88</span>/
                                            <span>部门</span>
                                        </div>
                                        <div class="item_box item_box_check"><i class="fa fa-check"></i></div>
                                    </div> -->
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary popups_submit">确认</button>
            </div>
        </div>
    </div>

</div>
<!-- 单选弹窗操作  -->
<script>
    var double_max;//扣分上限
    var first_id="";//初审人id
    var last_id="";//终审人id
    var principal_user_id="";//任务负责人id
    var now_item_name;//名字输入框
    var now_item_id;//id输入框
    var user_type;
    //确认按钮
    $('#myModal_single .popups_submit').click(function (e) {
        $('#myModal_single').modal('hide');
        var checked = $(".an_tree_list").find(".list_item_check");
        now_item_name.val(checked.attr("user_name"));
        now_item_id.val(checked.attr("user_id"));
        now_item_name.attr("limits_b",checked.attr("limits_b"))
    });
    //当弹窗关闭时执行重置弹窗
    $('#myModal_single').on('hidden.bs.modal', function () {
        // 执行一些动作...重置弹窗
        $(".an_tree_list .an_list_title").html("");
        $(".an_tree_list .an_list_con").html("");
        $(".tree_txt_active").removeClass("tree_txt_active");
        $(".an_tree_pack").hide();
        $(".an_tree .fa").removeClass("fa-caret-down").addClass("fa-caret-right");
        $("#myModal_single input[name='search_user_name']").val("");
    });
    // 记录人
    $("input[name='record_user_name']").focus(function () {
        $('#myModal_single').modal('show');
        double_max = 0;
        now_item_name = $(this);
        now_item_id = $("input[name='record_user_id']");//节点
        user_type = 0;
    });
    // 初审人
    $("input[name='first_check_user_name']").focus(function () {
        $('#myModal_single').modal('show');
        double_max = $("input[name='double_max']").val();
        now_item_name = $(this);//节点
        now_item_id = $("input[name='first_check_user_id']");//节点
        last_id = $("input[name='last_check_user_id']").val();//id值
        user_type = 1;
    });
    // 终审人
    $("input[name='last_check_user_name']").focus(function () {
        $('#myModal_single').modal('show');
        double_max = $("input[name='double_max']").val();
        now_item_name = $(this);//节点
        now_item_id = $("input[name='last_check_user_id']");//节点
        first_id = $("input[name='first_check_user_id']").val();//id值
        user_type = 2;
    });
</script>
<!-- 树结构js操作 单选  -->
<script>
    $("#myModal_single .an_tree").on("click", ".fa", function () {
        $(this).toggleClass("fa-caret-down");
        $(this).toggleClass("fa-caret-right");
        $(this).parents(".an_tree_set").eq(0).children(".an_tree_pack").toggle();
    });
    $("#myModal_single").on("click", ".an_tree_txt,.search_btn", function () {
        $(".an_tree").find(".tree_txt_active").removeClass("tree_txt_active");
        $(this).addClass("tree_txt_active");
        var department_id = $(this).attr("data_id");
        var department_name = $(this).html();
        var user_name = $("#myModal_single input[name='search_user_name']").val();
        // console.log(user_name);
        $.ajax({
            type: 'get',
            url: "{:url('base/base_department_per')}",
            data: {'department_id' : department_id,'user_name' : user_name},
            dataType:"json",
            success: function (data) {
                // var json = JSON.parse(data);
                // console.log(data);
                var content = '';
                $.each(data, function (index, value) {
                    if(value.limits==undefined){
                         var limits=0;
                    }else{
                        var limits=value.limits.b;
                    }
                    content += '<div class="an_list_item" user_name="'+value.name+'" user_id="'+value.id+'" limits_b="'+limits+'"><div class="item_info"><span class="name">' + value.name + '</span>/<span>' + value.job_number + '</span>/<span>' + value.department_name + '</span></div><div class="item_box "><i class="fa fa-check"></i></div></div>'
                });
                $('.an_list_con').html("");
                $('.an_list_con').append(content);
                $('.an_list_title').html(department_name + data.length + '人');
            }
        })
    });
    $("#myModal_single .an_tree_list").on("click", ".an_list_item", function () {
        $(this).siblings().removeClass("list_item_check");
        $(this).toggleClass("list_item_check")
    })
</script>
<!-- 递归填充目录 单选  -->
<script>
    var department = "";
    $.ajax({
        type: 'get',
        url: "{:url('base/base_department_page')}",
        dataType:"json",
        async: false,
        success: function (data) {
            // eventList = JSON.parse(data);
            department = data;
        }
    })
    var an_tree = ergodic(department)
    $("#myModal_single .an_tree").append(an_tree);
    function ergodic(data) {
        var content = '';
        $.each(data, function (index, value) {
            if (value.children != "") {
                var children = ergodic(value.children);
                content += '<div class="an_tree_set"><div class="an_tree_entry"><div class="an_tree_main"><span class="an_tree_icon"><i class="fa fa-caret-right"></i></span><span class="an_tree_txt" data_id="' + value.id + '" data_pid="' + value.pid + '">' + value.title + '</span></div></div><div class="an_tree_pack">' + children + '</div></div>';
            } else {
                content += '<div class="an_tree_set"><div class="an_tree_entry"><div class="an_tree_main"><span class="an_tree_icon"></span><span class="an_tree_txt" data_id="' + value.id + '" data_pid="' + value.pid + '">' + value.title + '</span></div></div><div class="an_tree_pack"></div></div>';
            }
        });
        return content;
    }
</script>



<!-- 拟稿提交按钮触发弹窗 -->
<script>
    $(".audit_sub_submit,.bh_sub_submit,.ch_sub_submit").click(function () {
        var item = $(this);
        var className = item.attr("class");
        var form = item.parents(".form-horizontal");
        var fuser_id = form.attr('data-fuser');
        var luser_id = form.attr('data-luser');
        var status = form.attr('data-status');
        var user_id = "{$user_id}";
        if((status == 1 && fuser_id == user_id)||(status == 2 && luser_id == user_id)){
            item.parents(".form-horizontal").find(".submits").click();
        }else {
            $('#myModal2').modal('show');
            $("#tips_submit").click(function () {
                var check_opinion = $("#check_opinion_textarea").val();
                if (className.indexOf("bh_sub_submit") != -1) {
                    if (check_opinion == '') {
                        layui.layer.msg('驳回意见必填！');
                        return false;
                    }
                }
                item.parents(".form-horizontal").find(".check_opinion").val(check_opinion);
                item.parents(".form-horizontal").find(".submits").click();
                $('#myModal2').modal('hide');
            });
        }
        return false;
    });
</script>
<!-- 拟稿提交按钮触发弹窗DOM结构 -->
<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2">
    <div class="modal-dialog" role="document">
        <div class="modal-content move" style="height: 280px;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel2">提示</h4>
            </div>
            <div class="modal_body" style="width: 100%;padding: 20px;">
                <label style="width: 100%;margin: 0!important;">
                    请填写您的意见或理由：
                    <textarea name="check_opinion_textarea" id="check_opinion_textarea" cols="45" rows="5"
                              style="display: block;width: 100%;max-height: 100px; margin:0;padding: 10px;border-radius: 5px;"
                              placeholder="可以输入一千字"></textarea>
                </label>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" id="tips_submit">确认</button>
            </div>
        </div>
    </div>
</div>

{/block}
